from django.urls import path
from rest_framework.routers import DefaultRouter
from . import views

router = DefaultRouter()
# 在这里添加ViewSet路由

urlpatterns = [
    # 用户认证相关接口 - 注意：主urls.py已经包含api前缀
    path('register/', views.register, name='register'),  # 用户注册
    path('login/', views.login, name='login'),  # 用户登录（可能与主urls.py中的JWT冲突）
    path('login-by-phone/', views.login_by_phone, name='login_by_phone'),  # 手机号登录
    path('refresh-token/', views.refresh_token, name='refresh_token'),  # Token刷新
    path('logout/', views.logout, name='logout'),  # 用户登出
    path('guest-login/', views.guest_login, name='guest_login'),  # 游客登录 (扩展)
    
    # 用户信息
    path('me/', views.get_current_user, name='current_user'),
    path('profile/update/', views.update_profile, name='update_profile'),  # 更新个人资料
    path('avatar/update/', views.update_avatar, name='update_avatar'),  # 更新头像
    path('search/', views.search_users, name='search_users'),  # 搜索用户和企业
    path('password/change/', views.change_password, name='change_password'),  # 修改密码
    path('work-orders/', views.get_user_work_orders, name='get_user_work_orders'),  # 获取用户工单
    
    # 账号管理新增接口
    path('profile/', views.get_user_profile, name='get_user_profile'),  # 获取用户个人资料
    path('password/update/', views.update_password, name='update_password'),  # 更新密码
    
    # 企业相关
    path('companies/', views.company_list, name='company_list'),  # GET(列表)/POST(创建)
    path('companies/<int:pk>/', views.company_detail, name='company_detail'),  # GET(详情)/PUT(更新)/DELETE(删除)
    path('companies/<int:pk>/employees/', views.company_employees, name='company_employees'),
    # path('companies/<int:pk>/departments/', views.company_departments, name='company_departments'),
    
    # 企业员工
    path('company-employees/', views.employee_list, name='employee_list'),  # GET(列表)/POST(创建)
    path('company-employees/<int:pk>/', views.employee_detail, name='employee_detail'),  # GET(详情)/PUT(更新)/DELETE(删除)
    
    # 园区员工
    path('profiles/park-employees/', views.park_employee_list, name='park_employee_list'),
    path('profiles/park-employees/<int:pk>/', views.park_employee_detail, name='park_employee_detail'),
    
    # 访客管理
    path('visitors/', views.visitor_list, name='visitor_list'),
    path('visitors/<int:pk>/', views.visitor_detail, name='visitor_detail'),
    path('search-visitors/', views.search_visitors, name='search_visitors'),
    
    # Dashboard统计接口
    path('employees/count/', views.employee_count, name='employee_count'),  # 园区员工数量
    path('company-employees/count/', views.company_employee_count, name='company_employee_count'),  # 企业员工数量
    path('visitors/count/', views.visitor_count, name='visitor_count'),  # 访客数量
    path('employees/', views.company_employee_list, name='company_employee_list'),
    path('employee-profile/', views.get_employee_profile, name='get_employee_profile'),
    path('employee-profile/update/', views.update_employee_profile, name='update_employee_profile'),
]

urlpatterns += router.urls 